#include "../import/head.h"
#include "export.h"
#include "../global/head.h"
#include "../impl/head.h"

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace xos_xml
{
    int create( xos::i_xos * pXosImpl, i_xml_mgr ** ppv )
    {
        int nRet = 0;

        if( 0 == nRet )
        {
            if( !ppv )
            {
                nRet = 1;
            }
            else
            {
                *ppv = 0;
            }
        }

        if( 0 == nRet )
        {
            if( g_pSysData )
            {
                nRet = 1;
            }
        }

        if( 0 == nRet )
        {
            g_pSysData = new sys_data( pXosImpl );

            if( !g_pSysData )
            {
                nRet = 1;
            }
        }

        if( 0 == nRet )
        {
            nRet = g_pSysData->init();
        }

        if( 0 == nRet )
        {
            *ppv = new xml_impl;
        }

        if( !( *ppv ) )
        {
            nRet = 1;
        }

        if( 0 != nRet )
        {
            if( g_pSysData )
            {
                g_pSysData->term();
                delete g_pSysData;
                g_pSysData = 0;
            }
        }

        return nRet;
    }

} // xos_xml
